import { createApp } from 'vue';
import App from './App.vue';
import { setupI18N } from './locales';
import { useInstallApp } from './hooks/use-app';
import { setupStore } from './store';
import { setupRouterGuard } from './router/guard';
import { Interceptors } from './http';
import { router, setupRouter } from './router';
import VueHashCalendar from 'vue3-hash-calendar';
import 'vue3-hash-calendar/es/index.css';
import '@/styles/index.less';
// 2. 引入组件样式
if (import.meta.env.DEV) {
	import('vant/lib/index.css');
}
import { registerCommonComp, registerPageComp } from './register';
async function bootstrap() {
	const app = createApp(App);
	// 本地运行不用vite的自动导入 避免首次加载过慢
	if (import.meta.env.DEV) {
		const vant = await import('vant');
		app.use(vant);
	}
	//  安装应用
	useInstallApp();
	// //  设置国际化
	await setupI18N(app);
	//  配置store
	setupStore(app);
	//  设置路由
	setupRouter(app);
	//  设置路由守卫
	setupRouterGuard(router);
	//  设置拦截器
	Interceptors.getInstance(router);
	// 组件注册
	registerCommonComp(app);
	registerPageComp(app);
	//安装插件
	// useInstallPlugin(app);
	await router.isReady();
	app.use(VueHashCalendar);
	app.mount('#app');
}
bootstrap();
